package cn.wolfcode.redis.service.impl;

import cn.wolfcode.redis.service.IArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;

@Service
public class ArticleServiceImpl implements IArticleService {
    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    @Override
    public int inscrease(int id) {
        String key = "viewnum:"+id;
        Long increment = stringRedisTemplate.opsForValue().increment(key);
        return increment.intValue();
    }
}
